package com.songlin.houxin.admin.controller;


import com.songlin.houxin.admin.api.dto.EnterprisesAddDTO;
import com.songlin.houxin.admin.api.dto.EnterprisesDeleteDTO;
import com.songlin.houxin.admin.api.dto.EnterprisesListDTO;
import com.songlin.houxin.admin.api.dto.EnterprisesUpdateDTO;
import com.songlin.houxin.admin.api.vo.BasePageVO;
import com.songlin.houxin.admin.api.vo.EnterprisesVO;
import com.songlin.houxin.admin.service.EnterprisesService;
import com.songlin.houxin.common.core.util.R;
import com.songlin.pig.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jinYuLinLang
 * @version 1.0.0
 * @ClassName EnterprisesController.java
 * @Description <p></p>
 * @createTime 2022-03-06 11:50:00
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/enterprises")
@Api(value = "enterprises", tags = "企业信息表管理")
public class EnterprisesController {

    private final EnterprisesService enterprisesService;

    /**
     * 分页查询
     *
     * @param dto 企业信息表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/queryEnterprisesList")
    //@PreAuthorize("@pms.hasPermission('demo_enterprises_get')")
    public R<BasePageVO<EnterprisesVO>> queryEnterprisesList(@RequestBody EnterprisesListDTO dto) {
        return R.ok(enterprisesService.queryEnterprisesList(dto));
    }


    /**
     * 新增企业信息表
     *
     * @param dto 添加企业信息入参信息
     * @return R
     */
    @ApiOperation(value = "新增企业信息表", notes = "新增企业信息表")
    @SysLog("新增企业信息表")
    @PostMapping(value = "/addEnterprises")
    //@PreAuthorize("@pms.hasPermission('demo_enterprises_add')")
    public R<Void> addEnterprises(@RequestBody EnterprisesAddDTO dto) {
        enterprisesService.addEnterprises(dto);
        return R.ok();
    }

    /**
     * 修改企业信息表
     *
     * @param dto 企业信息表
     * @return R
     */
    @ApiOperation(value = "修改企业信息表", notes = "修改企业信息表")
    @SysLog("修改企业信息表")
    @PostMapping(value = "/updateEnterprises")
    //  @PreAuthorize("@pms.hasPermission('demo_enterprises_edit')")
    public R<Void> updateEnterprises(@RequestBody EnterprisesUpdateDTO dto) {
        enterprisesService.updateEnterprises(dto);
        return R.ok();
    }

    /**
     * 通过id删除企业信息表
     *
     * @param dto 入参信息
     * @return R
     */
    @ApiOperation(value = "通过id删除企业信息表", notes = "通过id删除企业信息表")
    @SysLog("通过id删除企业信息表")
    @PostMapping(value = "/deleteBatchEnterprises")
    // @PreAuthorize("@pms.hasPermission('demo_enterprises_del')")
    public R<Void> deleteBatchEnterprises(@RequestBody EnterprisesDeleteDTO dto) {
        enterprisesService.deleteBatchEnterprises(dto);
        return R.ok();
    }

}

